<template>
    <a-select show-search placeholder="选择事故快报中的井" v-model:value="wellVal" style="width: 250px" :options="wells"
        @change="handleChange"></a-select>
</template>
<script setup>
import { ref, computed } from 'vue';
import { queryList, queryLastList } from '@/api/salvage/accidentAlert.js'
const emit = defineEmits(['update:value', 'confirm']);
const props = defineProps({
    wellId: {
        type: String
    }
})
const wells = ref([])
const wellVal = ref([])
watch(() => props.wellId, () => {
    console.log('watch', props.wellId);
    wellVal.value = props.wellId
});
// const wellVal = computed({
//     get: () => props.value,
//     set: (val) => {
//         console.log('修改' + val)
//         emit('update:value', val)
//         emit('confirm', val)
//     }
// });
function handleChange(e) {
    emit("confirm", e);
}

function getList() {
    queryLastList({ pageSize: 9999, pageNum: 1 }).then(res => {
        console.log('事故快报井', res)
        let tarr = res.content
        tarr = tarr.map(ele => {
            ele.label = ele.wellId
            ele.value = ele.wellId
            return ele
        })
        wells.value = tarr
    })
}
getList()
</script>